<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .container {
            width: 100%;
            height: 100%;
        }

        h1 {
            text-align: center;
            padding: 20px 0;
        }

        p {
            font-size: 15px;
            color: grey;
            padding: 10px 0;
            text-align: center;
        }

        .row {
            display: flex;
            height: 50px;
            justify-content: center;
            align-items: center;
        }

        .row span {
            width: 100px;
        }

        .row .edit {
            width: 200px;
            height: 36px;
        }

        .row .submit {
            width: 300px;
            height: 30px;
            background-color: orange;
            color: #fff;
            border: none;
            /* 去掉按钮边框*/
        }

        .row .submit:active {
            background-color: grey;
        }
    </style>
</head>

<body>
    <div class="container">
        <h1>表白墙</h1>
        <p>输入后点击提交, 将会把消息显示在墙上</p>
        <div class="row">
            <span>谁:</span>
            <input type="text" class="edit">
        </div>
        <div class="row">
            <span>对谁:</span>
            <input type="text" class="edit">
        </div>
        <div class="row">
            <span>说什么:</span>
            <input type="text" class="edit">
        </div>
        <div class="row">
            <input type="button" value="提交" class="submit">
        </div>

        <ul class="list">
            <li class="list-item">

            </li>
        </ul>


        <script>

            var tjbutton = document.getElementsByClassName('submit')[0]
            var srk = document.getElementsByClassName('edit')

            tjbutton.onclick = function () {

                var me = srk[0].value
                var toyou = srk[1].value
                var say = srk[2].value

                if (me == 0 || toyou == 0 || say == 0) {
                    return
                }

                var row = document.createElement('div')
                row.className = 'row'
                row.innerHTML = `${me}对${toyou}说:${say}`

                var container = document.getElementsByClassName('container')[0]
                container.appendChild(row)

                for (var i = 0; i < srk.length; i++) {
                    srk[i].value = ''
                }




            }

































            // let tjbutton = document.querySelector('.submit')
            // let edits = document.querySelectorAll('.edit')

            // tjbutton.onclick = (() => {

            //     let me = edits[0].value;
            //     let toyou = edits[1].value;
            //     let say = edits[2].value;

            //     if (me == 0 || toyou == 0 || say == 0) {
            //         return;
            //     }

            //     let row = document.createElement('div');
            //     row.className = 'row'
            //     row.innerHTML = `${me} 对 ${toyou}说：${say}`

            //     let container = document.querySelector('.container')
            //     container.appendChild(row)

            //     for (let i = 0; i < edits.length; i++) {
            //         edits[i].value = ''
            //     }

            // })












































            // let edits = document.querySelectorAll('.edit')
            // let tjbutton = document.querySelector('.submit')
            // tjbutton.onclick = (() => {
            //     let me = edits[0].value;
            //     let toyou = edits[0].value;
            //     let say = edits[0].value;
            //     if (me == 0 || toyou == 0 || say == 0) {
            //         return;
            //     }

            //     let row = document.createElement('div')
            //     row.className = 'row'
            //     row.innerHTML = `${me}对${toyou}说${say}`

            //     let container = document.querySelector('.container')
            //     container.appendChild(row);

            //     for (let i = 0; i < edits.length; i++) {
            //         edits[i].value = ''
            //     }
            // })


        </script>
</body>

</html>